package com.hrms.controller;

import com.hrms.domain.Employee;
import com.hrms.domain.web.TableDataInfo;
import com.hrms.domain.web.AjaxResult;
import com.hrms.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 员工管理Controller
 * 
 * @author 老詹
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/admin/employee")
public class EmployeeController extends BaseController
{
    @Autowired
    private IEmployeeService employeeService;

    /**
     * 查询员工管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Employee employee)
    {
        startPage();
        List<Employee> list = employeeService.selectEmployeeList(employee);
        return getDataTable(list);
    }

    /**
     * 获取员工管理详细信息
     */
    @GetMapping(value = "/{empNo}")
    public AjaxResult getInfo(@PathVariable("empNo") Long empNo)
    {
        return success(employeeService.selectEmployeeByEmpNo(empNo));
    }

    /**
     * 新增员工管理
     */
    @PostMapping
    public AjaxResult add(@RequestBody Employee employee)
    {
        return toAjax(employeeService.insertEmployee(employee));
    }

    /**
     * 修改员工管理
     */
    @PutMapping
    public AjaxResult edit( @RequestBody Employee employee)
    {
        return toAjax(employeeService.updateEmployee(employee));
    }

    /**
     * 删除员工管理
     */
	@DeleteMapping("/{empNos}")
    public AjaxResult remove(@PathVariable Long[] empNos)
    {
        return toAjax(employeeService.deleteEmployeeByEmpNos(empNos));
    }
}
